﻿<Window x:Class="YsTiffConverter.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vm="clr-namespace:YsTiffConverter.ViewModel"
    Title="YS TIFF Converter" Height="407" Width="613" 
        Loaded="Window_Loaded" Icon="/YsTiffConverter;component/App.ico" WindowStartupLocation="CenterScreen">

    <Window.Resources>
        <vm:CommandProxy x:Key="CommandOpen"  Command="{Binding CommandOpen}" />
        <vm:CommandProxy x:Key="CommandPrevious"  Command="{Binding CommandPrevious}" />
        <vm:CommandProxy x:Key="CommandNext"  Command="{Binding CommandNext}" />
        <vm:CommandProxy x:Key="CommandSaveAsJpeg"  Command="{Binding CommandSaveAsJpeg}" />
        <vm:CommandProxy x:Key="CommandSaveAllAsJpeg"  Command="{Binding CommandSaveAllAsJpeg}" />

        <Style TargetType="Button">
            <Setter Property="Height" Value="23"/>
            <Setter Property="Width" Value="55"/>
            <Setter Property="Margin" Value="5,5,5,5"/>
        </Style>
    </Window.Resources>

    <Window.InputBindings>
        <KeyBinding Command="{StaticResource CommandOpen}" Gesture="CTRL+O"/>
        <KeyBinding Command="{StaticResource CommandSaveAsJpeg}" Gesture="CTRL+SHIFT+S"/>
        <KeyBinding Command="{StaticResource CommandSaveAllAsJpeg}" Gesture="CTRL+ALT+SHIFT+S"/>
    </Window.InputBindings>

    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Open" Command="{StaticResource CommandOpen}" InputGestureText="CTRL+O" />
                <MenuItem Header="_Save current frame as JPEG" Command="{StaticResource CommandSaveAsJpeg}" 
                          InputGestureText="CTL+SHIFT+S" />
                <MenuItem Header="_Save all frames as JPEG" Command="{StaticResource CommandSaveAllAsJpeg}" 
                          InputGestureText="CTL+ALT+SHIFT+S" />
                <Separator/>
                <MenuItem Header="E_xit" Click="CommandExitClick"/>
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_About" Click="MenuItemAbout_Click"/>
            </MenuItem>
        </Menu>

        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="File: "/>
                    <TextBlock>
                        <TextBlock.Text>
                            <Binding Path="TiffImage.FileName"/>
                        </TextBlock.Text>
                    </TextBlock>
                </StackPanel>
            </StatusBarItem>

            <StatusBarItem>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Page: "/>
                    <TextBlock>
                        <TextBlock.Text>
                            <Binding Path="TiffImage.ImagePage"/>
                        </TextBlock.Text>
                    </TextBlock>
                </StackPanel>
            </StatusBarItem>
        </StatusBar>

        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Command="{StaticResource CommandPrevious}">_Previous</Button>
            <Button Command="{StaticResource CommandNext}">_Next</Button>
        </StackPanel>

        <Border DockPanel.Dock="Bottom" Margin="5" BorderThickness="1" BorderBrush="Blue">
            <ScrollViewer>
                <Image Source="{Binding Path=TiffImage.CurrentFrame}" Name="image"/>
            </ScrollViewer>
        </Border>
    </DockPanel>
</Window>
